import { Pagination, PaginationProps } from 'antd';
import type { PaginationLocale } from 'antd/es/pagination/Pagination';
import './index.scss'

type xkPaginationOptions = {
    autoHide?: boolean;           // 数据不足时自动隐藏
    showPageSize?: boolean;       // 显示页码切换器
    locale?: PaginationLocale;    // 支持国际化覆盖
    customStyle?: React.CSSProperties; // 自定义style
} & Omit<PaginationProps, 'showSizeChanger'>

const XkPagination: React.FC<xkPaginationOptions> = ({
    total = 0,
    pageSize = 10,
    defaultCurrent = 1,
    autoHide = true,
    showPageSize = false,
    locale,
    showQuickJumper = false,
    showTitle = true,
    customStyle = {},
    ...restProps
}) => {
    if (autoHide && total <= pageSize) return null;


    return (
        <div className='flex content-center xk-pagination-wrapper'>
            <Pagination
                {...restProps}
                defaultCurrent={defaultCurrent}
                total={total}
                pageSize={pageSize}
                showSizeChanger={showPageSize}
                locale={locale}
                showQuickJumper={showQuickJumper}
                showTitle={showTitle}
                style={customStyle}
            />
        </div>
    );
};

export default XkPagination